#pragma once
#include "../../include/types.h"
#include "../../include/riscv.h"
#include "../proc/spinlock.h"
#include "../../include/memlayout.h"

// Long-term locks for processes
struct sleeplock {
    uint32 locked;       // Is the lock held?
    spinlock lk; // spinlock protecting this sleep lock
    
    // For debugging:
    char *name;        // Name of lock.
    int pid;           // Process holding lock
  };
  
  
void
initsleeplock(struct sleeplock *lk, char *name);

void
acquiresleep(struct sleeplock *lk);

void
releasesleep(struct sleeplock *lk);

int
holdingsleep(struct sleeplock *lk);